package com.xinzhiduming.mp3palyer;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import android.app.ActivityManager;
import android.content.Context;

public class Utils {
	public static boolean isServiceRunning(Context context, String className) {
		boolean isRunning = false;
		ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
		List<ActivityManager.RunningServiceInfo> setviceList = activityManager.getRunningServices(30);
		if (!(setviceList.size() > 0)) {
			return false;
		}
		for (int i = 0; i < setviceList.size(); i++) {
			if (setviceList.get(i).service.getClassName().equals(className) == true) {
				isRunning = true;
				break;
			}
		}
		return isRunning;
	}

	public static ArrayList<File> sortFiles(File[] fileList) {
		if (fileList != null) {
			ArrayList<File> arrayListFile = new ArrayList<File>();
			for (File f : fileList) {
				arrayListFile.add(f);
			}
			Collections.sort(arrayListFile);
			return arrayListFile;
		}
		return null;
	}
}
